<%--
  Created by IntelliJ IDEA.
  User: 57998
  Date: 2020/10/28
  Time: 15:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta name="content-type" content="text/html; charset=UTF-8">
		<script type="text/javascript" class="autoinsert" src="js/jquery-2.2.0.min.js"></script>
		<link rel="stylesheet" type="text/css" href="css/layer.css"/>
		<script type="text/javascript" class="autoinsert" src="js/layer.js"></script>
		<title>视频播放</title>
	</head>
	<body style="margin: 0;">
		<input id="look" type="hidden" value="${look}"></div>
		<div style="cursor: pointer;font-size: 20px;background-color: cornsilk;color: blue;font-weight: 500;align-items: center;
					height: 8%;display: flex;justify-content: center;" onclick="to_home()">
			点击此处返回首页
		</div>
		<video id="video-active" class="video-active" width="100%" height="600" controls="controls">
			<!-- <source src="vedio/text01.mp4" type="video/mp4"> -->
			<source src="${src}" type="video/mp4">
		</video>
		<input id="current" type="hidden" value="0"></div>
		<input id="fid" type="hidden" value="${fid}"></div>
		<script type="text/javascript">
			window.onload = function () {
				if($("#look").val()=="nologin"){
					layer.msg('该影片为会员专享，您尚未登录，请先登录!', {
						time: 1500
					});
					setTimeout(function (){
						window.location.href="${pageContext.request.contextPath}/home";
					}, 1700);
				}else if($("#look").val()=="novip"){
					layer.msg('该影片为会员专享，您不是会员无法观看，请先升级会员!', {
						time: 1500
					});
					setTimeout(function (){
						window.location.href="${pageContext.request.contextPath}/home";
					}, 1700);
				}else{
					console.log($("#look").val());
				}
			}
			$(document).ready(function() {
				$("#video-active").on(
					"timeupdate",
					function(event) {
						getVideotime(this.currentTime);
					}
				);
			});
			function getVideotime(currentTime) {
				$("#current").val(currentTime);
			}
			function to_home(){
				$.ajax({
					type: "POST",
					url: "${pageContext.request.contextPath}/addlooktime",
					data: {
						fid: $("#fid").val(),
						time_temp: Math.round($("#current").val())
					},
					dataType: "json",
					success: function(result) {
						console.log(result.code)
						if (result.code == "1") {
							window.location.href="${pageContext.request.contextPath}/update_fid?fid_new="+$("#fid").val()+"&time_temp="+Math.round($("#current").val());
						} else if (result.code == "2") {
							window.location.href="${pageContext.request.contextPath}/home";
						} else {
							layer.msg('系统错误，请刷新后重试!', {
								time: 1500
							});
						}
					},
					error: function() {
						layer.msg('系统错误，请刷新后重试!', {
							time: 1500
						});
					}
				});
			}
		</script>
	</body>
</html>
